﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualBasic.ApplicationServices;

namespace MyTwentiethWPFDemo
{
    class SingleInstanceAppWrapper : WindowsFormsApplicationBase
    {
        public SingleInstanceAppWrapper()
        {
            this.IsSingleInstance = true;
        }

        private WpfApp app;

        protected override bool OnStartup(StartupEventArgs eventArgs)
        {
            app = new WpfApp();
            app.Run();
            return false;
            //return base.OnStartup(eventArgs);
        }

        protected override void OnStartupNextInstance(StartupNextInstanceEventArgs eventArgs)
        {
            base.OnStartupNextInstance(eventArgs);
            app.ShowWindow();
        }
    }
}
